/**
* AutoSWF - Cody Cushing. March 26, 2009
* Copyright (c) 2009 Cody Cushing
* No use restrictions. Maintain this notice in all versions. 
**/

package com.autoswf.taskrunner.loadtasks
{
	import com.autoswf.taskrunner.IRequest;
	import com.autoswf.taskrunner.ITask;
	import com.autoswf.taskrunner.ITaskFactory;
	
	/**
	 * Returns a LoadTask for the LoadRequest type.
	 */		
	public class LoadTaskFactory implements ITaskFactory
	{
		/**
		 * Constructor.
		 */		
		public function LoadTaskFactory()
		{
			
		}
		
		/**
		 * Returns a load task for the request type.
		 */		
		public function getTask(request:IRequest):ITask
		{
			var loadRequest:LoadRequest = LoadRequest(request);
			switch(loadRequest.type)
			{
				case "xml": case "string": case "urlloader": case "[class URLLoader]":
				{
					return new URLLoaderTask(loadRequest);
				}
				case "image": case "jpg": case "png": case "gif": case "swf": case "loader": case "[class Loader]":
				{
					return new LoaderTask(loadRequest);
				}
			}
			throw new ArgumentError("Unsupported reguest type: " + loadRequest.type);
		}

	}
}